#include"headfile.h"

void amp_init(){
    adc_init(AMP1,ADC_SYSclk_DIV_16);
	adc_init(AMP2,ADC_SYSclk_DIV_16);
	adc_init(AMP3,ADC_SYSclk_DIV_16);
    adc_init(AMP4,ADC_SYSclk_DIV_16);
}
float amp_valule[4]={0};
void amp_exe(){
    uint16 one[10],two[10],three[10],four[10];
	int i;	
	for(i=0;i<10;i++){
		one[i]=adc_once(AMP1,ADC_12BIT);
		two[i]=adc_once(AMP2,ADC_12BIT);
		three[i]=adc_once(AMP3,ADC_12BIT);
        four[i]=adc_once(AMP4,ADC_12BIT);
	}
	for(i=0;i<10;i++){
		one[0]+=one[i];
	  	two[0]+=two[i];
        three[0]+=three[i];
	  	four[0]+=four[i];
	}
	amp_valule[0]=(float)one[0]/10;
	amp_valule[1]=(float)two[0]/10;
	amp_valule[2]=(float)three[0]/10;
    amp_valule[3]=(float)four[0]/10;

}

void amp_lcd_msg(void){
	lcd_clear(WHITE);
	lcd_showstr(0,0,"1:");lcd_showstr(0,1,"2:");lcd_showstr(0,2,"3:");lcd_showstr(0,3,"4:");
	lcd_showfloat(20,0,amp_valule[0],6,6);               				
	lcd_showfloat(20,1,amp_valule[1],6,6);               				
	lcd_showfloat(20,2,amp_valule[2],6,6);
	lcd_showfloat(20,3,amp_valule[3],6,6);
}